#!/usr/local/bin/perl

push @INC, "./";

#needed library
require(multiwordnet_ram);

use strict;

set_mwn_path("../lib/mwndata1.4.3/");

# store all semantic types of a synset
my %st_hash = (); 
# store the id of a semantic type
my %syn_hash = ();

sub extract_semtype {
	my ($lemma, $pos, $lang) = @_;
	
	my @synset_ids = get_synsets($lemma,$pos,$lang);
	my @semtype;
	if ($#synset_ids > 0) {
		for my $id (@synset_ids) {
			my @new_semtype = join(" ", get_synset_sumo($id));
			@semtype = (@semtype, @new_semtype);
			$st_hash{$id} = \@new_semtype; #assign to the reference instead of value
			for my $type (@new_semtype) {
				$syn_hash{$type} = $id;
			}
		}
	} 
	return @semtype
}

my @semtype = extract_semtype("student", "n", "english");
for my $sym (@semtype) {
	print $sym . "\n";
}
for my $key (keys %st_hash) {
	print "$key => $st_hash{$key}\n";
}
for my $key (keys %syn_hash) {
	print "$key => $syn_hash{$key}\n"
}